package bocchi.card;

import bocchi.base.BaseCustomCard;
import bocchi.BocchiCore;
import bocchi.base.BaseCustomPower;
import bocchi.general.Util;
import bocchi.power.ErosionPower;
import com.evacipated.cardcrawl.mod.stslib.actions.common.AllEnemyApplyPowerAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;

public class Ash extends BaseCustomCard {
    private static final String RAW_ID = Ash.class.getSimpleName();
	public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public Ash() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        BaseCustomPower power = new BaseCustomPower(RAW_ID, AbstractPower.PowerType.BUFF, player, magicNumber) {
            @Override
            public void updateDescription() {
                description = String.format(descriptions[0], amount);
            }

            @Override
            public int onAttacked(DamageInfo info, int damageAmount) {
                if (info.type == DamageInfo.DamageType.NORMAL) {
                    flash();
                    addToTop(new AllEnemyApplyPowerAction(owner, amount, monster -> new ErosionPower(monster, amount)));
                }

                return damageAmount;
            }
        };

        Util.applyPower(player, player, power);
    }
}
